package org.jeecg.modules.solitaire_app.app.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.solitaire_app.app.entity.VO.YsyMarketnewsVO;
import org.jeecg.modules.solitaire_app.app.entity.YsyMarketnews;
import org.jeecg.modules.solitaire_app.app.mapper.YsyMarketnewsMapper;
import org.jeecg.modules.solitaire_app.app.service.IYsyMarketnewsService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: 行情早报
 * @Author: jeecg-boot
 * @Date:   2024-03-28
 * @Version: V1.0
 */
@Service
@DS("ysy_db")
public class YsyMarketnewsServiceImpl extends ServiceImpl<YsyMarketnewsMapper, YsyMarketnews> implements IYsyMarketnewsService {

    @Override
    public Result<PageInfo<YsyMarketnewsVO>> getMarketNewsList(Integer pageNo, Integer pageSize) {
        Result<PageInfo<YsyMarketnewsVO>> result = new Result<>();
        try {
            PageHelper.startPage(pageNo,pageSize);
            List<YsyMarketnewsVO> ysyMarketnews = this.baseMapper.getMarketNewsList();
            PageInfo pageInfo = new PageInfo(ysyMarketnews);
            result.setSuccess(true);
            result.setCode(200);
            result.setResult(pageInfo);
            return result;
        }catch (Exception e){
            result.setSuccess(false);
            result.setCode(500);
            result.setMessage("服务器响应失败");
            return result;
        }
    }
}
